<?php
/**
 * @author: Trinh Thanh Phuong
 * @since: 27/12/2012
 * @todo : Xử lý cập nhật bai giang
 */
class mtl_modTraining extends Efy_DB_Connection {
	/**
	*  @author: Trinh Thanh Phuong
	*  @since: 27/12/2012
	*  @param: $spName : Ten storprocedure
	*		  $arrParameter: Mang tham so truyen vao SP
	*		  $type: phuong thuc chay sp: 1 : GetAll, 0: Getsingle
	*		  $bug: 1: neu muon bug loi
	 */
	public function mTLSPRun($spName, $arrParameter, $type, $bug = 0){
		$arrResult = array(); 
		$sql = "Exec $spName ".$this->exportSql($arrParameter);
        //echo $sql; exit;
		if($bug)
			eval('echo $sql; exit;');
		try{
			if($type)
				$arrResul = $this->adodbQueryDataInNameMode($sql); 
			else
				$arrResul = $this->adodbExecSqlString($sql); 				
		}catch (Exception $e){ 
			echo $e->getMessage();
		}
		return $arrResul; 
	}
	public function exportSql($arrParameter){ 
		$sql =''; 
		foreach ($arrParameter as $key => $value) { 
			if($sql !=''){
				$sql .= ",'" . $value . "'"; 
			}else{
				$sql .= "'" . $value . "'"; 
			}
		}
		return $sql; 
	}
}
?>
